<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改文章')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body>
    <div class="main-content">
        <form class="form-horizontal m" id="form-content-edit" th:object="${cmsContent}">
            <input name="id" th:field="*{id}" type="hidden">
            
                    	<div class="row">
        		<div class="col-sm-6">
        			 <div class="form-group">    
		                <label class="col-sm-4 control-label">文章标题：</label>
		                <div class="col-sm-8">
		                    <input name="contentTitle" th:field="*{contentTitle}" class="form-control" type="text">
		                </div>
		            </div>
        		</div>
        		<div class="col-sm-6">
        			 <div class="form-group">    
		                <label class="col-sm-4 control-label">所属栏目：</label>
		                <div class="col-sm-8">
		                	<div class="input-group">
			                    <input id="treeId" name="contentCategoryId" type="hidden" th:value="${cmsCategory?.id}"/>
			                    <input class="form-control" type="text" onclick="selectCategoryTree()" id="treeName" readonly="true" th:value="${cmsCategory?.categoryTitle}">
			                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
			                </div>
		                </div>
		            </div>
        		</div>        		
        	</div>
        	<div class="row">
        		<div class="col-sm-6">
        			 <div class="form-group">    
	                    <label class="col-sm-4 control-label">文章类型：</label>
		                <div class="col-sm-8">
		                    <select name="contentType" class="form-control m-b">
		                        <option value="">所有</option>
		                    </select>
		                </div>
		            </div>
        		</div>
        		<div class="col-sm-6">
        			 <div class="form-group">    
		                <label class="col-sm-4 control-label">发布时间：</label>
		                <div class="col-sm-8">
		                	<div class="input-group date">
		                        <input name="contentDatetime" th:value="${#dates.format(cmsContent.contentDatetime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        		<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
		                    </div>
		                </div>
		            </div>
        		</div>        		
        	</div>            
        	<div class="row">
        		<div class="col-sm-6">
        			 <div class="form-group">    
	                    <label class="col-sm-4 control-label">文章作者：</label>
		                <div class="col-sm-8">
		                    <input name="contentAuthor" th:field="*{contentAuthor}" class="form-control" type="text">
		                </div>
		            </div>
        		</div>
        		<div class="col-sm-6">
        			 <div class="form-group">    
		                <label class="col-sm-4 control-label">文章来源：</label>
		                <div class="col-sm-8">
		                    <input name="contentSource" th:field="*{contentSource}" class="form-control" type="text">
		                </div>
		            </div>
        		</div>        		
        	</div>         
        	<div class="row">
        		<div class="col-sm-6">
        			 <div class="form-group">    
	                    <label class="col-sm-4 control-label">是否显示：</label>
		                <div class="col-sm-8">
		                    <input name="contentDisplay" th:field="*{contentDisplay}" class="form-control" type="text">
		                </div>
		            </div>
        		</div>
        		<div class="col-sm-6">
        			 <div class="form-group">    
		                <label class="col-sm-4 control-label">自定义顺序：</label>
		                <div class="col-sm-8">
		                    <input name="contentSort" th:field="*{contentSort}" class="form-control" type="number">
		                </div>
		            </div>
        		</div>        		
        	</div> 
        	<div class="row">
                <div class="col-sm-12">        
		        	<div class="form-group">
		                <label class="col-xs-2 control-label">文章缩略图：</label>
		                <div class="col-xs-10">
		                    <textarea name="contentImg" class="form-control">[[*{contentImg}]]</textarea>
		                </div>
		            </div>
		        </div>
		    </div>
        	<div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">关键字：</label>
                        <div class="col-xs-10">
                            <input name="contentKeyword" th:field="*{contentKeyword}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
        	<div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">描述：</label>
                        <div class="col-xs-10">
                            <input name="contentDescription" th:field="*{contentDescription}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">正文：</label>
                        <div class="col-xs-10">
                            <script id="editor" name="contentDetails" type="text/plain" ></script>
                            <input id="uedata" th:field="*{contentDetails}" type="hidden"/>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: ueditor" />
    <script th:inline="javascript">
        var prefix = ctx + "cms/content";
        
        var ue = UE.getEditor('editor');
        ue.ready(function() {//编辑器初始化完成再赋值
            ue.setContent($("#uedata").val());  //赋值给UEditor
        });
        
 	   function getContent() {
 	       return UE.getEditor('editor').getContent();
 	   }
 	   function getContentTxt() {
 	       return UE.getEditor('editor').getContentTxt();
 	   }
 	   $("#editor").css("height","380px");
        
        $("#form-content-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-content-edit').serialize());
            }
        }

        $("input[name='contentDatetime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        /*分类-新增-选择分类树*/
        function selectCategoryTree() {
            var options = {
                title: '分类选择',
                width: "380",
                url: ctx + "cms/category/selectCategoryTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }
        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
               $("#treeId").val(body.find('#treeId').val());
               $("#treeName").val(body.find('#treeName').val());
               layer.close(index);
        }
        
    </script>
</body>
</html>